var link = document.querySelector(".link");
function showCustomAlert(msg, sty) {
  // 创建提示框元素
  var customAlert = document.createElement("div");
  customAlert.className = "custom-alert";
  var icon = document.createElement("i");
  var message = document.createElement("i");
  if (sty) {
    icon.className = "iconfont icon-right-1-copy";
    customAlert.style.backgroundColor = "#def5de";
    customAlert.style.color = "#09713a";
  } else if (!sty) {
    icon.className = "iconfont icon-cuowuguanbiquxiao-yuankuang";
    customAlert.style.backgroundColor = "#ffeded";
    customAlert.style.color = "#ff717c";
  }
  // 创建提示文本
  message.innerHTML = msg;
  // 将提示文本添加到提示框中
  customAlert.appendChild(icon);
  customAlert.appendChild(message);

  // 将提示框添加到页面中
  document.body.appendChild(customAlert);
  //一定时间后自动关闭提示框
  setTimeout(function () {
    document.body.removeChild(customAlert);
  }, 1500); // 1500毫秒（1.5秒）后关闭提示框
}
// 确认框
function customConfirm(msg, callback) {
  const confirmBox = document.createElement("div");
  confirmBox.classList.add("confirm-box");
  confirmBox.innerHTML = `
    <p>${msg}</p>
    <button id="confirmYes">确定</button>
    <button id="confirmNo">取消</button>
  `;
  document.body.appendChild(confirmBox);
  // 确认按钮点击事件
  const confirmYesBtn = confirmBox.querySelector("#confirmYes");
  confirmYesBtn.addEventListener("click", () => {
    document.body.removeChild(confirmBox);
    callback(true);
  });
  // 取消按钮点击事件
  const confirmNoBtn = confirmBox.querySelector("#confirmNo");
  confirmNoBtn.addEventListener("click", () => {
    document.body.removeChild(confirmBox);
    callback(false);
  });
}

let flag = 0;
var eye = document.querySelector(".iconfont");
eye.onclick = function () {
  let password = document.querySelector(".loginPwd");
  if (flag == 0) {
    password.type = "text";
    eye.innerHTML = "&#xe715;";
    flag = 1;
  } else {
    password.type = "password";
    eye.innerHTML = "&#xe714;";
    flag = 0;
  }
};

let loginBtn = document.querySelector(".login-btn");

// loginBtn.onclick=function (){
//   let email=document.querySelector(".loginE").value;
//   let password=document.querySelector(".loginPwd").value;
//   if(email==""||password==""){
//     return showCustomAlert("邮箱或密码为空");
//   }
//
// }
function dosubmit() {
  let email = document.querySelector(".loginE").value;
  let password = document.querySelector(".loginPwd").value;
  if (email == "" || password == "") {
    showCustomAlert("邮箱或密码为空");

    return false;
  } else {
    return true;
  }
}
